package com.design.facade;

import java.util.ArrayList;
import java.util.List;

public abstract class AbstractScenePattern implements ScenePattern{

    List<IMachine>machineList=new ArrayList<>();
    @Override
    public void addMachine(IMachine machine) {
        machineList.add(machine);
    }

    @Override
    public void deleteMachine(IMachine machine) {
        machineList.remove(machine);
    }

    @Override
    public void oneKeyOn() {
        machineList.stream().parallel().forEach(machine -> {
            machine.on();
        });
    }

    @Override
    public void oneKeyOff() {
        machineList.stream().parallel().forEach(machine -> {
            machine.off();
        });
    }
}
